﻿Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Linq
Imports System.Text
Imports System.Windows.Thickness
Imports System.Windows.Media.Animation
Imports System.Windows.Threading

Public Class WindowZHT

    Private the_Zht_list As ButtonArray = New ButtonArray()
    Private the_Multiple_list As ButtonArray = New ButtonArray()
    Private the_TorF_list As ButtonArray = New ButtonArray()

    Private the_rb_list As rbArray = New rbArray()
    Private the_ck_list As ckArray = New ckArray()

    Private buttonBrush As New LinearGradientBrush()    '按钮初始化颜色
    Private buttonBrushA As New LinearGradientBrush()    '当前题按钮颜色
    Private buttonBrushErr As New LinearGradientBrush()     '错题按钮颜色
    Private buttonBrushWring As New LinearGradientBrush()  '漏答题按钮提醒颜色

    Private DispatcherTimer As Windows.Threading.DispatcherTimer = New Windows.Threading.DispatcherTimer()



#Region "初始化部分"
    Private Sub MainWindow_Initialized(sender As Object, e As System.EventArgs) Handles Me.Initialized
        'Me.Topmost = True               '在最前
        'Me.ShowInTaskbar = False          '不在任务栏中显示本程序
        tempButton = Nothing
        buttonBrush.StartPoint = New Point(0.5, 1)
        buttonBrush.EndPoint = New Point(0.5, 0)
        buttonBrush.GradientStops.Add(New GradientStop(Colors.SkyBlue, 0))
        buttonBrush.GradientStops.Add(New GradientStop(Colors.White, 0.9))

        buttonBrushA.StartPoint = New Point(0.5, 1)
        buttonBrushA.EndPoint = New Point(0.5, 0)
        buttonBrushA.GradientStops.Add(New GradientStop(Colors.DarkSeaGreen, 0))
        buttonBrushA.GradientStops.Add(New GradientStop(Colors.White, 0.9))

        buttonBrushErr.StartPoint = New Point(0.5, 1)
        buttonBrushErr.EndPoint = New Point(0.5, 0)
        buttonBrushErr.GradientStops.Add(New GradientStop(Colors.Red, 0))
        buttonBrushErr.GradientStops.Add(New GradientStop(Colors.White, 0.9))

        buttonBrushWring.StartPoint = New Point(0.5, 1)
        buttonBrushWring.EndPoint = New Point(0.5, 0)
        buttonBrushWring.GradientStops.Add(New GradientStop(Colors.Yellow, 0))
        buttonBrushWring.GradientStops.Add(New GradientStop(Colors.White, 0.9))

        If AB = 1 Then
            '多选题
            For i As Int16 = 1 To 15
                Dim the_button As Button = New Button()
                the_Multiple_list.Add(the_button)
                the_button.Name = "Multiple" & i
                the_button.Content = i
                the_button.Width = 30
                the_button.Height = 25
                the_button.Margin = New Thickness(5)
                the_button.Padding = New Thickness(1)
                the_button.Background = buttonBrush
                the_button.Visibility = Windows.Visibility.Visible
                WPMultiple.Children.Add(the_button)
                AddHandler the_button.Click, AddressOf the_Multiple_list_click
            Next

            '判断题
            For i As Int16 = 1 To 20
                Dim the_button As Button = New Button()
                the_TorF_list.Add(the_button)
                the_button.Name = "TorF" & i
                the_button.Content = i
                the_button.Width = 30
                the_button.Height = 25
                the_button.Margin = New Thickness(5)
                the_button.Padding = New Thickness(1)
                the_button.Background = buttonBrush
                the_button.Visibility = Windows.Visibility.Visible
                WPTorF.Children.Add(the_button)
                AddHandler the_button.Click, AddressOf the_TorF_list_click
            Next

            '综合题
            For i As Int16 = 1 To 5
                For j As Int16 = 1 To 5
                    Dim the_button As Button = New Button()
                    the_Zht_list.Add(the_button)
                    the_button.Name = "Zht" & i & j
                    the_button.Content = i & "-" & j
                    the_button.Width = 35
                    the_button.Height = 25
                    the_button.Margin = New Thickness(5)
                    the_button.Padding = New Thickness(1)
                    the_button.Background = buttonBrush
                    the_button.Visibility = Windows.Visibility.Visible
                    WPDart.Children.Add(the_button)
                    AddHandler the_button.Click, AddressOf the_Zht_list_click
                Next
            Next
            epMultiple.IsExpanded = True
            epTorF.IsExpanded = True
            epZht.IsExpanded = True
        End If

        pb1.Value = 120
        pb1.Minimum = 0
        pb1.Maximum = 120

        AddHandler DispatcherTimer.Tick, AddressOf dispatcherTimer_Tick
        DispatcherTimer.Interval = New TimeSpan(0, 0, 1)

        'DispatcherTimer.Interval = New TimeSpan(0, 0, 0)

        'DispatcherTimer.Start()
        tempButton = the_Multiple_list.Item(0)
        Dim rea As RoutedEventArgs = New RoutedEventArgs()
        the_Multiple_list_click(tempButton, rea)
        '初始化默认值,模式从第一大题第一小题开始
        tempNo = 1
        txtTt.Text = ""
        txtD.Text = "多选题"
        txtX.Text = tempNo
        txtDoc.Text = arrString(4)


    End Sub
#End Region


#Region "单击按钮，各题按钮事件"
    Private Sub the_Zht_list_click(sender As System.Object, e As System.Windows.RoutedEventArgs)
        tempButton.Background = buttonBrush
        DispatcherTimer.Stop()
        txtD.Text = "综合题"
        txtDoc.Text = arrString(6)
        tempButton = CType(sender, Button)
        tempNoJ = CType(Mid(tempButton.Content.ToString(), 1, 1), Int16)
        tempNo = CType(Mid(tempButton.Content.ToString(), 3, 1), Int16)
        txtX.Text = tempButton.Content.ToString()

        tempButton.Background = buttonBrushA
        If arrComprehensive(tempNoJ, 0, 2) <= 10 Then
            pb1.Foreground = Brushes.Crimson
        Else
            pb1.Foreground = Brushes.LimeGreen
        End If
        txtT.Text = arrComprehensive(tempNoJ, 0, 0)
        txtbSecond.Text = arrComprehensive(tempNoJ, 0, 2) & "秒"

        If tempButton.Name = "Zht" & tempNoJ & tempNo Then
            'MessageBox.Show("ok" & tempNo)

            txtTt.Text = arrComprehensive(tempNoJ, tempNo, 0)

            '加载答案信息
            the_ck_list.Clear()         '清空答案选项，以便变换新的答案选项显示
            spAnwers.Children.Clear()



            For i As Int16 = 1 To 4
                Dim the_ck As CheckBox = New CheckBox()
                Dim txt_ck As TextBlock = New TextBlock()
                the_ck_list.Add(the_ck)
                the_ck.Name = "ckZht" & i
                txt_ck.Text = arrComprehensive(tempNoJ, tempNo, i)
                txt_ck.TextWrapping = TextWrapping.Wrap
                the_ck.Content = txt_ck
                the_ck.FontSize = 15
                the_ck.FontWeight = Windows.FontWeights.Black
                the_ck.Margin = New Thickness(5)
                the_ck.Padding = New Thickness(1)
                If getMAnswer(arrComprehensive(tempNoJ, tempNo, 6), i) Then
                    the_ck.IsChecked = True
                Else
                    the_ck.IsChecked = False
                End If
                the_ck.Visibility = Windows.Visibility.Visible
                spAnwers.Children.Add(the_ck)
                AddHandler the_ck.Checked, AddressOf the_ck_list_checked
                AddHandler the_ck.Unchecked, AddressOf the_ck_list_UnChecked
            Next

            pb1.Value = arrComprehensive(tempNoJ, 0, 2)
            pb1.Minimum = 0
            pb1.Maximum = 600
            DispatcherTimer.Start()

        End If
    End Sub

    Private Sub the_Multiple_list_click(sender As System.Object, e As System.Windows.RoutedEventArgs)
        txtTt.Text = ""
        tempButton.Background = buttonBrush
        DispatcherTimer.Stop()
        txtD.Text = "多选题"
        txtDoc.Text = arrString(4)
        tempButton = CType(sender, Button)
        tempNo = CType(tempButton.Content.ToString(), Int16)
        txtX.Text = tempNo
        tempButton.Background = buttonBrushA
        If arrStringMultiple(tempNo, 6) <= 10 Then
            pb1.Foreground = Brushes.Crimson
        Else
            pb1.Foreground = Brushes.LimeGreen
        End If
        txtbSecond.Text = arrStringMultiple(tempNo, 6) & "秒"

        If tempButton.Name = "Multiple" & tempNo Then
            'MessageBox.Show("ok" & tempNo)

            txtT.Text = arrStringMultiple(tempNo, 0)

            '加载答案信息
            the_ck_list.Clear()         '清空答案选项，以便变换新的答案选项显示
            spAnwers.Children.Clear()



            For i As Int16 = 1 To 5
                Dim the_ck As CheckBox = New CheckBox()
                Dim txt_ck As TextBlock = New TextBlock()
                the_ck_list.Add(the_ck)
                the_ck.Name = "ckMultiple" & i
                txt_ck.Text = arrStringMultiple(tempNo, i)
                txt_ck.TextWrapping = TextWrapping.Wrap
                the_ck.Content = txt_ck
                the_ck.FontSize = 15
                the_ck.FontWeight = Windows.FontWeights.Black
                the_ck.Margin = New Thickness(5)
                the_ck.Padding = New Thickness(1)
                If getMAnswer(arrStringMultiple(tempNo, 8), i) Then
                    the_ck.IsChecked = True
                Else
                    the_ck.IsChecked = False
                End If
                the_ck.Visibility = Windows.Visibility.Visible
                spAnwers.Children.Add(the_ck)
                AddHandler the_ck.Checked, AddressOf the_ck_list_checked
                AddHandler the_ck.Unchecked, AddressOf the_ck_list_UnChecked
            Next

            pb1.Value = arrStringMultiple(tempNo, 6)
            pb1.Minimum = 0
            pb1.Maximum = 120
            DispatcherTimer.Start()

        End If
    End Sub

    Private Sub the_TorF_list_click(sender As System.Object, e As System.Windows.RoutedEventArgs)
        txtTt.Text = ""
        tempButton.Background = buttonBrush
        DispatcherTimer.Stop()
        txtD.Text = "判断题"
        txtDoc.Text = arrString(5)
        tempButton = CType(sender, Button)
        tempNo = CType(tempButton.Content.ToString(), Int16)
        txtX.Text = tempNo
        tempButton.Background = buttonBrushA
        If arrStringTorF(tempNo, 4) <= 10 Then
            pb1.Foreground = Brushes.Crimson
        Else
            pb1.Foreground = Brushes.LimeGreen
        End If
        txtbSecond.Text = arrStringTorF(tempNo, 4) & "秒"

        If tempButton.Name = "TorF" & tempNo Then
            'MessageBox.Show("ok" & tempNo)

            txtT.Text = arrStringTorF(tempNo, 0)

            '加载答案信息
            the_rb_list.Clear()         '清空答案选项，以便变换新的答案选项显示
            spAnwers.Children.Clear()

            For i As Int16 = 1 To 3
                Dim the_rb As RadioButton = New RadioButton()
                the_rb_list.Add(the_rb)
                the_rb.Name = "rbTorF" & i
                the_rb.Content = arrStringTorF(tempNo, i)
                the_rb.FontSize = 15
                the_rb.FontWeight = Windows.FontWeights.Black
                the_rb.Margin = New Thickness(5)
                the_rb.Padding = New Thickness(1)
                If getAboutAnswer(arrStringTorF(tempNo, 6), txtD.Text) = i Then
                    the_rb.IsChecked = True
                End If
                the_rb.Visibility = Windows.Visibility.Visible
                spAnwers.Children.Add(the_rb)
                AddHandler the_rb.Checked, AddressOf the_rb_list_checked
            Next

            pb1.Value = arrStringTorF(tempNo, 4)
            pb1.Minimum = 0
            pb1.Maximum = 30
            DispatcherTimer.Start()
        End If
    End Sub
#End Region


#Region "时间控件间隔触发事件"
    Private Sub dispatcherTimer_Tick(ByVal sender As Object, ByVal e As EventArgs)
        If AB = 1 Then
            'Multiple
            If InStr(tempButton.Name.ToString, "Multiple") Then
                arrStringMultiple(tempNo, 6) = pb1.Value
                txtTt.Text = ""
                If pb1.Value <= 10 Then
                    pb1.Foreground = Brushes.Crimson
                Else
                    pb1.Foreground = Brushes.LimeGreen
                End If

                If pb1.Value <= 0 Then
                    'MsgBox("ok")
                    tempButton.Background = buttonBrush
                    tempButton.IsEnabled = False
                    tempButton = Nothing
                    DispatcherTimer.Stop()
                    If tempNo >= 15 Then
                        tempNo = 1
                        tempButton = the_TorF_list.Item(0)
                        txtT.Text = tempNo
                        Dim rea As RoutedEventArgs = New RoutedEventArgs()
                        the_TorF_list_click(tempButton, rea)
                        Exit Sub
                    Else
                        tempButton = the_Multiple_list.Item(tempNo)
                        txtX.Text = tempNo + 1
                        Dim rea As RoutedEventArgs = New RoutedEventArgs()
                        the_Multiple_list_click(tempButton, rea)
                        'MsgBox("123")
                    End If
                End If
                pb1.Value = pb1.Value - 1
                txtbSecond.Text = pb1.Value & " 秒"
            End If

            'TorF
            If InStr(tempButton.Name.ToString, "TorF") Then
                arrStringTorF(tempNo, 4) = pb1.Value
                txtTt.Text = ""
                If pb1.Value <= 10 Then
                    pb1.Foreground = Brushes.Crimson
                Else
                    pb1.Foreground = Brushes.LimeGreen
                End If

                If pb1.Value <= 0 Then
                    'MsgBox("ok")
                    tempButton.IsEnabled = False
                    tempButton.Background = buttonBrush
                    tempButton = Nothing
                    DispatcherTimer.Stop()


                    If tempNo >= 20 Then
                        tempNoJ = 1
                        tempNo = 1
                        tempButton = the_Zht_list.Item(0)
                        Dim rea As RoutedEventArgs = New RoutedEventArgs()
                        the_Zht_list_click(tempButton, rea)
                        Exit Sub
                    Else
                        tempButton = the_TorF_list.Item(tempNo)
                        txtX.Text = tempNo + 1
                        Dim rea As RoutedEventArgs = New RoutedEventArgs()
                        the_TorF_list_click(tempButton, rea)
                        'MsgBox("123")
                    End If
                End If
                pb1.Value = pb1.Value - 1
                txtbSecond.Text = pb1.Value & " 秒"
            End If

            'Zht
            Dim tempLL As Int16 = 0
            If InStr(tempButton.Name.ToString, "Zht") Then
                If tempNoJ = 0 Then tempNoJ = 1
                tempLL = ((tempNoJ - 1) * 5) + tempNo               '当前题号
                arrComprehensive(tempNoJ, 0, 2) = pb1.Value
                If pb1.Value <= 10 Then
                    pb1.Foreground = Brushes.Crimson
                Else
                    pb1.Foreground = Brushes.LimeGreen
                End If

                If pb1.Value <= 0 Then
                    'MsgBox("ok")
                    tempButton.Background = buttonBrush
                    tempButton.IsEnabled = False
                    tempButton = Nothing
                    DispatcherTimer.Stop()

                    If tempLL >= 25 Then
                        MsgBox("最后一题，请检查交卷！")
                        tempNo = 1
                        tempButton = the_Multiple_list.Item(0)
                        Dim rea As RoutedEventArgs = New RoutedEventArgs()
                        the_Multiple_list_click(tempButton, rea)
                        Exit Sub
                    Else
                        tempButton = the_Zht_list.Item(tempLL)

                        txtX.Text = tempButton.Content.ToString()

                        Dim rea As RoutedEventArgs = New RoutedEventArgs()
                        the_Zht_list_click(tempButton, rea)
                        'MsgBox("123")
                    End If
                End If
                pb1.Value = pb1.Value - 1
                txtbSecond.Text = pb1.Value & " 秒"
            End If
        End If
    End Sub
#End Region


#Region "单选按钮事件"
    Private Sub the_rb_list_checked(sender As System.Object, e As System.Windows.RoutedEventArgs)
        If InStr(tempButton.Name.ToString, "TorF") Then
            tempRB = CType(sender, RadioButton)
            If tempRB.Name = "rbTorF1" Then
                'MsgBox("ok1" & tempNo)
                arrStringTorF(tempNo, 6) = "对"
            End If
            If tempRB.Name = "rbTorF2" Then
                'MsgBox("ok2" & tempNo)
                arrStringTorF(tempNo, 6) = "错"
            End If
            If tempRB.Name = "rbTorF3" Then
                'MsgBox("ok2" & tempNo)
                arrStringTorF(tempNo, 6) = "放弃"
            End If
            'tempNo = CType(tempRB.Content.ToString(), Int16)
        End If

    End Sub
#End Region

#Region "多选按钮事件"
    Private Sub the_ck_list_checked(sender As System.Object, e As System.Windows.RoutedEventArgs)
        If InStr(tempButton.Name.ToString, "Zht") Then
            tempCK = CType(sender, CheckBox)
            If tempCK.Name = "ckZht1" Then
                'MsgBox("ok1" & tempNo)
                arrComprehensive(tempNoJ, tempNo, 6) = setMAnswer(arrComprehensive(tempNoJ, tempNo, 6), "A")
            End If
            If tempCK.Name = "ckZht2" Then
                'MsgBox("ok2" & tempNo)
                arrComprehensive(tempNoJ, tempNo, 6) = setMAnswer(arrComprehensive(tempNoJ, tempNo, 6), "B")
            End If
            If tempCK.Name = "ckZht3" Then
                'MsgBox("ok3" & tempNo)
                arrComprehensive(tempNoJ, tempNo, 6) = setMAnswer(arrComprehensive(tempNoJ, tempNo, 6), "C")
            End If
            If tempCK.Name = "ckZht4" Then
                'MsgBox("ok4" & tempNo)
                arrComprehensive(tempNoJ, tempNo, 6) = setMAnswer(arrComprehensive(tempNoJ, tempNo, 6), "D")
            End If
            'tempNo = CType(tempRB.Content.ToString(), Int16)
        End If

        If InStr(tempButton.Name.ToString, "Multiple") Then
            tempCK = CType(sender, CheckBox)
            If tempCK.Name = "ckMultiple1" Then
                'MsgBox("ok1" & tempNo)
                arrStringMultiple(tempNo, 8) = setMAnswer(arrStringMultiple(tempNo, 8), "A")
            End If
            If tempCK.Name = "ckMultiple2" Then
                'MsgBox("ok2" & tempNo)
                arrStringMultiple(tempNo, 8) = setMAnswer(arrStringMultiple(tempNo, 8), "B")
            End If
            If tempCK.Name = "ckMultiple3" Then
                'MsgBox("ok3" & tempNo)
                arrStringMultiple(tempNo, 8) = setMAnswer(arrStringMultiple(tempNo, 8), "C")
            End If
            If tempCK.Name = "ckMultiple4" Then
                'MsgBox("ok4" & tempNo)
                arrStringMultiple(tempNo, 8) = setMAnswer(arrStringMultiple(tempNo, 8), "D")
            End If
            If tempCK.Name = "ckMultiple5" Then
                'MsgBox("ok5" & tempNo)
                arrStringMultiple(tempNo, 8) = setMAnswer(arrStringMultiple(tempNo, 8), "E")
            End If
            'tempNo = CType(tempRB.Content.ToString(), Int16)
        End If
    End Sub

    Private Sub the_ck_list_UnChecked(sender As System.Object, e As System.Windows.RoutedEventArgs)
        If InStr(tempButton.Name.ToString, "Zht") Then
            tempCK = CType(sender, CheckBox)
            If tempCK.Name = "ckZht1" Then
                'MsgBox("ok1" & tempNo)
                arrComprehensive(tempNoJ, tempNo, 6) = setMA(arrComprehensive(tempNoJ, tempNo, 6), "A")
            End If
            If tempCK.Name = "ckZht2" Then
                'MsgBox("ok2" & tempNo)
                arrComprehensive(tempNoJ, tempNo, 6) = setMA(arrComprehensive(tempNoJ, tempNo, 6), "B")
            End If
            If tempCK.Name = "ckZht3" Then
                'MsgBox("ok3" & tempNo)
                arrComprehensive(tempNoJ, tempNo, 6) = setMA(arrComprehensive(tempNoJ, tempNo, 6), "C")
            End If
            If tempCK.Name = "ckZht4" Then
                'MsgBox("ok4" & tempNo)
                arrComprehensive(tempNoJ, tempNo, 6) = setMA(arrComprehensive(tempNoJ, tempNo, 6), "D")
            End If
        End If

        If InStr(tempButton.Name.ToString, "Multiple") Then
            tempCK = CType(sender, CheckBox)
            If tempCK.Name = "ckMultiple1" Then
                'MsgBox("ok1" & tempNo)
                arrStringMultiple(tempNo, 8) = setMA(arrStringMultiple(tempNo, 8), "A")
            End If
            If tempCK.Name = "ckMultiple2" Then
                'MsgBox("ok2" & tempNo)
                arrStringMultiple(tempNo, 8) = setMA(arrStringMultiple(tempNo, 8), "B")
            End If
            If tempCK.Name = "ckMultiple3" Then
                'MsgBox("ok3" & tempNo)
                arrStringMultiple(tempNo, 8) = setMA(arrStringMultiple(tempNo, 8), "C")
            End If
            If tempCK.Name = "ckMultiple4" Then
                'MsgBox("ok4" & tempNo)
                arrStringMultiple(tempNo, 8) = setMA(arrStringMultiple(tempNo, 8), "D")
            End If
            If tempCK.Name = "ckMultiple5" Then
                'MsgBox("ok5" & tempNo)
                arrStringMultiple(tempNo, 8) = setMA(arrStringMultiple(tempNo, 8), "E")
            End If
        End If
    End Sub
#End Region



#Region "上一题，下一题按钮事件"
    Private Sub btnNext_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles btnNext.Click
        If IsNothing(tempButton) Then
            MsgBox("答题时间到，请交卷！")
            Exit Sub
        End If
        DispatcherTimer.Stop()
        If AB = 1 Then
            'Multiple
            If InStr(tempButton.Name.ToString, "Multiple") Then
                txtTt.Text = ""
                If tempNo >= 15 Then
                    tempNo = 1
                    tempButton.Background = buttonBrush
                    'txtX.Text = tempNo
                    tempButton = the_TorF_list.Item(0)
                    Dim rea As RoutedEventArgs = New RoutedEventArgs()
                    the_TorF_list_click(tempButton, rea)
                    Exit Sub
                Else
                    arrStringMultiple(tempNo, 6) = pb1.Value
                    tempButton.Background = buttonBrush
                    tempButton = the_Multiple_list.Item(tempNo)
                    txtX.Text = tempNo
                    Do While tempButton.IsEnabled = False
                        'MsgBox("ok")
                        tempNo = tempNo + 1
                        tempButton = the_Multiple_list.Item(tempNo)
                        txtX.Text = tempNo
                        'MsgBox("123")
                    Loop
                    Dim rea As RoutedEventArgs = New RoutedEventArgs()
                    the_Multiple_list_click(tempButton, rea)
                End If
            End If
            'TorF
            If InStr(tempButton.Name.ToString, "TorF") Then
                txtTt.Text = ""
                If tempNo >= 20 Then
                    arrStringTorF(tempNo, 4) = pb1.Value
                    tempButton.Background = buttonBrush
                    tempNoJ = 1
                    tempNo = 1
                    tempButton = the_Zht_list.Item(0)
                    Dim rea As RoutedEventArgs = New RoutedEventArgs()
                    the_Zht_list_click(tempButton, rea)
                    Exit Sub
                Else
                    arrStringTorF(tempNo, 4) = pb1.Value
                    tempButton.Background = buttonBrush
                    tempButton = the_TorF_list.Item(tempNo)
                    txtX.Text = tempNo
                    Do While tempButton.IsEnabled = False
                        'MsgBox("ok")
                        tempNo = tempNo + 1
                        tempButton = the_TorF_list.Item(tempNo)
                        txtX.Text = tempNo
                        'MsgBox("123")
                    Loop
                    Dim rea As RoutedEventArgs = New RoutedEventArgs()
                    the_TorF_list_click(tempButton, rea)
                End If
            End If
            'Zht
            Dim tempLL As Int16 = 0
            If InStr(tempButton.Name.ToString, "Zht") Then
                tempLL = ((tempNoJ - 1) * 5) + tempNo
                If tempLL >= 25 Then
                    MsgBox("最后一题，请提交卷子！")
                    DispatcherTimer.Start()
                    Exit Sub
                Else
                    arrComprehensive(tempNoJ, 0, 2) = pb1.Value
                    tempButton.Background = buttonBrush
                    tempButton = the_Zht_list.Item(tempLL)
                    txtX.Text = tempButton.Content.ToString()
                    Do While tempButton.IsEnabled = False
                        'MsgBox("ok")
                        tempLL = tempLL + 1
                        tempButton = the_Zht_list.Item(tempLL)
                        txtX.Text = tempButton.Content.ToString()
                        'MsgBox("123")
                    Loop
                    Dim rea As RoutedEventArgs = New RoutedEventArgs()
                    the_Zht_list_click(tempButton, rea)
                End If
            End If


        End If
    End Sub

    Private Sub btnPrevious_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles btnPrevious.Click
        If IsNothing(tempButton) Then
            MsgBox("答题时间到，请交卷！")
            Exit Sub
        End If
        DispatcherTimer.Stop()
        If AB = 1 Then
            'Multiple
            If InStr(tempButton.Name.ToString, "Multiple") Then
                If tempNo <= 1 Then
                    MsgBox("已经是第一题！")
                    DispatcherTimer.Start()
                    Exit Sub
                Else
                    arrStringMultiple(tempNo, 6) = pb1.Value
                    tempButton.Background = buttonBrush
                    tempNo = tempNo - 2
                    tempButton = the_Multiple_list.Item(tempNo)
                    txtX.Text = tempNo
                    Do While tempButton.IsEnabled = False
                        'MsgBox("ok")
                        tempNo = tempNo - 1
                        tempButton = the_Multiple_list.Item(tempNo)
                        txtX.Text = tempNo
                        'MsgBox("123")
                    Loop
                    Dim rea As RoutedEventArgs = New RoutedEventArgs()
                    the_Multiple_list_click(tempButton, rea)
                End If
            End If
            'TorF
            If InStr(tempButton.Name.ToString, "TorF") Then
                If tempNo <= 1 Then
                    tempNo = 15
                    tempButton.Background = buttonBrush
                    'txtX.Text = tempNo
                    tempButton = the_Multiple_list.Item(14)
                    Dim rea As RoutedEventArgs = New RoutedEventArgs()
                    the_Multiple_list_click(tempButton, rea)
                    Exit Sub
                Else
                    arrStringTorF(tempNo, 4) = pb1.Value
                    tempButton.Background = buttonBrush
                    tempNo = tempNo - 2
                    tempButton = the_TorF_list.Item(tempNo)
                    txtX.Text = tempNo
                    Do While tempButton.IsEnabled = False
                        'MsgBox("ok")
                        tempNo = tempNo + 1
                        tempButton = the_TorF_list.Item(tempNo)
                        txtX.Text = tempNo
                        'MsgBox("123")
                    Loop
                    Dim rea As RoutedEventArgs = New RoutedEventArgs()
                    the_TorF_list_click(tempButton, rea)
                End If
            End If


            'Zht
            Dim tempLL As Int16 = 0
            If InStr(tempButton.Name.ToString, "Zht") Then
                tempLL = tempNoJ * tempNo
                If tempLL <= 1 Then
                    tempNo = 20
                    tempButton.Background = buttonBrush
                    tempButton = the_TorF_list.Item(19)
                    Dim rea As RoutedEventArgs = New RoutedEventArgs()
                    the_TorF_list_click(tempButton, rea)
                    Exit Sub
                Else
                    arrComprehensive(tempNoJ, 0, 2) = pb1.Value
                    tempButton.Background = buttonBrush
                    tempLL = tempLL - 2
                    tempButton = the_Zht_list.Item(tempLL)
                    txtX.Text = tempButton.Content.ToString()
                    Do While tempButton.IsEnabled = False
                        'MsgBox("ok")
                        tempLL = tempLL - 1
                        tempButton = the_Zht_list.Item(tempLL)
                        txtX.Text = tempButton.Content.ToString()
                        'MsgBox("123")
                    Loop
                    Dim rea As RoutedEventArgs = New RoutedEventArgs()
                    the_Zht_list_click(tempButton, rea)
                End If
            End If
        End If
    End Sub
#End Region


#Region "交卷判分按钮事件"
    Private Sub btnCommit_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles btnCommit.Click

        '交卷判分
        If AB = 1 Then
            Dim intZht As Double = 0
            For i As Int16 = 1 To 5
                For j As Int16 = 1 To 5
                    If arrComprehensive(i, j, 6) = arrComprehensive(i, j, 5) Then
                        intZht = intZht + 2
                    Else
                        If Len(arrComprehensive(i, j, 5)) > Len(arrComprehensive(i, j, 6)) Then
                            If InStr(arrComprehensive(i, j, 5), arrComprehensive(i, j, 6)) > 0 Then
                                For k As Int16 = 1 To Len(arrComprehensive(i, j, 6))
                                    If InStr(arrComprehensive(i, j, 5), Mid(arrComprehensive(i, j, 6), k, 1)) > 0 Then
                                        intZht = intZht + 0.5
                                    End If
                                Next
                            End If
                        End If
                    End If
                Next
            Next


            Dim intMultiple As Double = 0
            For i As Int16 = 1 To 15
                If arrStringMultiple(i, 8) = arrStringMultiple(i, 7) Then
                    intMultiple = intMultiple + 2
                Else
                    If Len(arrStringMultiple(i, 7)) > Len(arrStringMultiple(i, 8)) Then
                        If InStr(arrStringMultiple(i, 7), arrStringMultiple(i, 8)) > 0 Then
                            For j As Int16 = 1 To Len(arrStringMultiple(i, 8))
                                If InStr(arrStringMultiple(i, 7), Mid(arrStringMultiple(i, 8), j, 1)) > 0 Then
                                    intMultiple = intMultiple + 0.5
                                End If
                            Next
                        End If
                    End If
                End If
            Next
            Dim intTorF As Double = 0
            For i As Int16 = 1 To 20
                If arrStringTorF(i, 6) = arrStringTorF(i, 5) Then
                    intTorF = intTorF + 1
                Else
                    If arrStringTorF(i, 6) <> "" And arrStringTorF(i, 6) <> "放弃" Then
                        intTorF = intTorF - 1
                    End If
                End If
            Next
            If intTorF > 0 Then
                ZZZ = intMultiple + intZht + intTorF
            Else
                ZZZ = intMultiple + intZht
            End If
        End If

        Dim tempJJ As Boolean = True                    '漏题交卷确认判断标志
        If ltck() = False Then
            If MsgBox("你在有时间的前提下还存在没答的题【黄色题标记】，请确认是否交卷？", vbYesNo, "漏答题交卷确认") = MsgBoxResult.Yes Then
                Dim wo As winOver = New winOver()
                wo.Show()
                Me.Close()
                Exit Sub
            Else
                tempNo = 1
                tempButton = the_Multiple_list.Item(0)
                tempJJ = False
            End If
        End If


        If tempJJ Then
            If MsgBox("请确认交卷？", vbYesNo, "交卷确认") = MsgBoxResult.Yes Then
                Dim wo As winOver = New winOver()
                wo.Show()
                Me.Close()
                Exit Sub
            Else
                Exit Sub
            End If
        End If
    End Sub




    Function ltck() As Boolean           '没答的漏答的题，颜色提醒检测
        ltck = True
        For i As Int16 = 1 To 20
            If arrStringTorF(i, 6) = "" Then
                ltck = False
                tempButton = the_TorF_list.Item(i - 1)
                tempButton.Background = buttonBrushWring
            End If
        Next

        For i As Int16 = 1 To 15
            If arrStringMultiple(i, 8) = "" Then
                ltck = False
                tempButton = the_Multiple_list.Item(i - 1)
                tempButton.Background = buttonBrushWring
            End If
        Next

        For i As Int16 = 1 To 5
            For j As Int16 = 1 To 5
                If arrComprehensive(i, j, 6) = "" Then
                    ltck = False
                    tempButton = the_Zht_list.Item((((i - 1) * 5) + j) - 1)
                    tempButton.Background = buttonBrushWring
                End If
            Next
        Next
    End Function

#End Region
End Class
